package cash_access;

import java.io.IOException;

import mware_lib.ManagerSkeleton;
import mware_lib.namensdienst.communication.ObjectConnection;
import mware_lib.namensdienst.communication.Server;

public class AccountSkeleton implements Runnable{

	private Server server;
	private ManagerSkeleton ms;
	private boolean running;
	
	public AccountSkeleton(int myPort, ManagerSkeleton ms) {
		this.ms = ms;
		this.running = true;
		
		try {
			server = new Server(myPort);
		} catch (IOException e) {
			e.printStackTrace();
		}
	}

	public void run() {
		while(running){
			try {
				ObjectConnection myConnection = server.getConnection();
				
				AccountWorker worker = new AccountWorker(myConnection, ms);
				Thread t = new Thread(worker);
				t.start();
				//neuen Worker erstellen, welcher myConnection mitbekommt und so Messages empfangen und senden kann
				//und die myConnection closen (myConnection.close();)
				
			} catch (IOException e) {
				e.printStackTrace();
			}
		}
	}
	
	
	
	
}
